using System;
using System.Data;
using System.Data.SqlClient;
using Microsoft.ApplicationBlocks.Data;

namespace shfa.snomtastic.data
{
    public partial class SqlDataProvider
    {

        public Guid InsertPhone(string macAddress, Guid userId, Guid configurationId, string ipAddress, Guid subnetId, string serialNumber, string userAgent, Guid modelId, string model, Guid firmwareId, string firmware, string bootLoader, string extension, DateTime firstFailedDate, bool registrationFailed, int reRegisterCount, string httpClientPass, DateTime createdDate, DateTime updatedDate)
		{
            return new Guid(Convert.ToString(SqlHelper.ExecuteScalar(ConnectionString, "sp_PhoneInsert", macAddress, GetNull(userId), GetNull(configurationId), ipAddress, GetNull(subnetId), serialNumber, userAgent, GetNull(modelId), model, GetNull(firmwareId), firmware, bootLoader, extension, GetNull(firstFailedDate), registrationFailed, reRegisterCount, httpClientPass, GetNull(createdDate), GetNull(updatedDate))));
		}

        public int UpdatePhone(Guid phoneId, string macAddress, Guid userId, Guid configurationId, string ipAddress, Guid subnetId, string serialNumber, string userAgent, Guid modelId, string model, Guid firmwareId, string firmware, string bootLoader, string extension, DateTime firstFailedDate, bool registrationFailed, int reRegisterCount, string httpClientPass, DateTime createdDate, DateTime updatedDate)
		{
            return Convert.ToInt32(SqlHelper.ExecuteScalar(ConnectionString, "sp_PhoneUpdate", GetNull(phoneId), macAddress, GetNull(userId), GetNull(configurationId), ipAddress, GetNull(subnetId), serialNumber, userAgent, GetNull(modelId), model, GetNull(firmwareId), firmware, bootLoader, extension, GetNull(firstFailedDate), registrationFailed, reRegisterCount, httpClientPass, GetNull(createdDate), GetNull(updatedDate)));
		}

        public int DeletePhone(Guid phoneId) 
		{
            return Convert.ToInt32(SqlHelper.ExecuteScalar(ConnectionString, "sp_PhoneDelete", phoneId));
		}

        public DataRow SelectPhone(Guid phoneId) 
        {    
			DataSet ds = SqlHelper.ExecuteDataset(ConnectionString, "sp_PhoneSelect", phoneId);
            if (ds.Tables.Count > 0)
                if (ds.Tables[0].Rows.Count > 0)
                    return ds.Tables[0].Rows[0];

            return null;
		}

		public DataTable SelectPhones() 
		{
            return SqlHelper.ExecuteDataset(ConnectionString, "sp_PhoneSelectAll").Tables[0];
        }

		public DataTable SelectPhonesByConfiguration(Guid configurationId) 
		{
            return SqlHelper.ExecuteDataset(ConnectionString, "sp_PhoneSelectByConfiguration", configurationId).Tables[0];
        }

		public DataTable SelectPhonesByFirmware(Guid firmwareId) 
		{
            return SqlHelper.ExecuteDataset(ConnectionString, "sp_PhoneSelectByFirmware", firmwareId).Tables[0];
        }

		public DataTable SelectPhonesByModel(Guid modelId) 
		{
            return SqlHelper.ExecuteDataset(ConnectionString, "sp_PhoneSelectByModel", modelId).Tables[0];
        }

		public DataTable SelectPhonesBySubnet(Guid subnetId) 
		{
            return SqlHelper.ExecuteDataset(ConnectionString, "sp_PhoneSelectBySubnet", subnetId).Tables[0];
        }

		public DataTable SelectPhonesByUser(Guid userId) 
		{
            return SqlHelper.ExecuteDataset(ConnectionString, "sp_PhoneSelectByUser", userId).Tables[0];
        }

    }

}
